{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "ZlboV5Zt1buQ"
   },
   "source": [
    "# TensorFlow2.0教程-自定义训练（基础）\n",
    "tensorflow2.0推荐使用tf.keras这样的高级api来构建网络，但tensorflow仍然保持了灵活的构造网络的低级api，我们这节就来介绍怎么通过使用这些低级api构建一个神经网络并训练。\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 35
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 10273,
     "status": "ok",
     "timestamp": 1559221761435,
     "user": {
      "displayName": "Will Chen",
      "photoUrl": "",
      "userId": "01179718990779759737"
     },
     "user_tz": -480
    },
    "id": "NuAeh0Fn0ffq",
    "outputId": "87efd080-b991-4b97-e2fc-1c88a09d13f3"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2.0.0-alpha0\n"
     ]
    }
   ],
   "source": [
    "from __future__ import absolute_import, print_function, division, unicode_literals\n",
    "!pip install -q tensorflow==2.0.0-alpha0\n",
    "import tensorflow as tf\n",
    "print(tf.__version__)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "KblizbY-5Jtj"
   },
   "source": [
    "##  一、Variables\n",
    "TensorFlow的张量是不可变的无状态对象。当我们有要改变的张量时，可以使用python的特性，把计算得到的值赋给这个python变量。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 143
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 803,
     "status": "ok",
     "timestamp": 1559222931093,
     "user": {
      "displayName": "Will Chen",
      "photoUrl": "",
      "userId": "01179718990779759737"
     },
     "user_tz": -480
    },
    "id": "UnUuvOYn280u",
    "outputId": "cb538471-592a-4376-d5bf-3052321b19e0"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tf.Tensor(\n",
      "[[4. 4. 4. 4. 4. 4.]\n",
      " [4. 4. 4. 4. 4. 4.]\n",
      " [4. 4. 4. 4. 4. 4.]\n",
      " [4. 4. 4. 4. 4. 4.]\n",
      " [4. 4. 4. 4. 4. 4.]\n",
      " [4. 4. 4. 4. 4. 4.]], shape=(6, 6), dtype=float32)\n"
     ]
    }
   ],
   "source": [
    "x = tf.ones([6,6])\n",
    "x = x + 3 # x+3后得到了一个新的张量，并把这个张量赋给x\n",
    "print(x)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "0b-EsceM8B-Q"
   },
   "source": [
    "然而机器学习中间需要变化的状态（每个参数朝损失变小的方向改变，所以TensorFlow也要内置有状态的操作，这就是Variables，它可以表示模型中的参数，而且方便高效。\n",
    "\n",
    "Variables是一个存在值的对象，当其被使用是，它被隐式地被从存储中读取，而当有诸如tf.assign_sub, tf.scatter_update这样的操作时，得到的新值会储存到原对象中。\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 53
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 741,
     "status": "ok",
     "timestamp": 1559223575052,
     "user": {
      "displayName": "Will Chen",
      "photoUrl": "",
      "userId": "01179718990779759737"
     },
     "user_tz": -480
    },
    "id": "ipYeAlhP7csm",
    "outputId": "efaaba7d-1517-45da-9429-41ae9a45db49"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<tf.Variable 'Variable:0' shape=() dtype=int32, numpy=6>\n",
      "<tf.Variable 'Variable:0' shape=() dtype=int32, numpy=15>\n"
     ]
    }
   ],
   "source": [
    "v = tf.Variable(2)\n",
    "v.assign(6)\n",
    "print(v)\n",
    "v.assign_add(tf.square(3))\n",
    "print(v)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "rUzj7ieg-EzI"
   },
   "source": [
    "注：梯度计算时会自动跟踪变量的计算（不用watch），对表示嵌入的变量，TensorFlow会默认使用稀疏更新，这样可以提高计算和存储效率。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "44Iuq8NA-wC_"
   },
   "source": [
    "## 二、示例：拟合线性模型\n",
    "\n",
    "使用Tensor， Variable和GradientTape这些简单的要是，就可以构建一个简单的模型。步骤如下：\n",
    "\n",
    "- 定义模型\n",
    "- 定义损失函数\n",
    "- 获取训练数据\n",
    "- 模型训练，使用优化器调整变量\n",
    "\n",
    "在下面我们会构造一个简单的线性模型：f(x) =  W + b,  它有2个变量W和b，同时我们会使用W=3.0，b=2.0来构造数据，用于学习。\n",
    "\n",
    "###１、定义模型\n",
    "我们把模型定义为一个简单的类，里面封装了变量和计算"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 35
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 1468,
     "status": "ok",
     "timestamp": 1559225737005,
     "user": {
      "displayName": "Will Chen",
      "photoUrl": "",
      "userId": "01179718990779759737"
     },
     "user_tz": -480
    },
    "id": "rvOw-KVK957v",
    "outputId": "8e7dd070-caf5-479b-e816-55929410f5b2"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tf.Tensor(10.0, shape=(), dtype=float32)\n"
     ]
    }
   ],
   "source": [
    "class Model(object):\n",
    "    def __init__(self):\n",
    "        # 初始化变量\n",
    "        self.W = tf.Variable(5.0)\n",
    "        self.b = tf.Variable(0.0)\n",
    "    \n",
    "    def __call__(self, x):\n",
    "        return self.W * x + self.b\n",
    "# 测试\n",
    "model = Model()\n",
    "print(model(2))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "m6EKTFkSDTuE"
   },
   "source": [
    "##２．定义损失函数\n",
    "损失函数测量给定输入的模型输出与期望输出的匹配程度。 这里使用标准的L2损失。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "LFAFmxyhDOKi"
   },
   "outputs": [],
   "source": [
    "def loss(predicted_y, true_y):\n",
    "    return tf.reduce_mean(tf.square(predicted_y - true_y))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "OpQvjudfD0xP"
   },
   "source": [
    "## 3.获取训练数据\n",
    "生成带有噪音的数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "jo81SIryC7Y_"
   },
   "outputs": [],
   "source": [
    "TRUE_W = 3.0\n",
    "TRUE_b = 2.0\n",
    "num = 1000\n",
    "\n",
    "# 随机输入\n",
    "inputs = tf.random.normal(shape=[num])\n",
    "# 随机噪音\n",
    "noise = tf.random.normal(shape=[num])\n",
    "\n",
    "# 构造数据\n",
    "outputs = TRUE_W * inputs + TRUE_b + noise\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "lZfyvhbTE9A6"
   },
   "source": [
    "在我们训练模型之前，让我们可以看到模型现在所处的位置。 我们将用红色绘制模型的预测，用蓝色绘制训练数据。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 305
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 1897,
     "status": "ok",
     "timestamp": 1559225738636,
     "user": {
      "displayName": "Will Chen",
      "photoUrl": "",
      "userId": "01179718990779759737"
     },
     "user_tz": -480
    },
    "id": "ZRcHF6ewEvVf",
    "outputId": "7953f827-62f9-4f1a-d991-db603620662c"
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD8CAYAAAB0IB+mAAAABHNCSVQICAgIfAhkiAAAAAlwS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Agg00Z6pEb4fEbnDcfM+AD/q17UkRUTu\nBfBbAH5VVa/0+3pozQ8B3CEinxSRUQBfAvBin6+JOrQmOJ8C8Laq/rt+X08SWvuFb2l9vxmmcCBw\nrMtTlc53APwcTAVIA2Yf3UyPukTkFIAbASy17vpBDiqPvgjgCQDbAHwI4LiqfqG/VxWeiOwB8O8B\nFAEcUdW5Pl9SbCLyHIDPwnRi/AmAr6vqU329qBhE5JcB/BcAfwoTFwDgn6rqS/27qnhE5E4AR2H+\nuysAeF5V/0Xgx+cl4BMRkb/cpHSIiMgfAz4R0ZBgwCciGhIM+EREQ4IBn4hoSDDgExENCQZ8IqIh\nwYBPRDQk/j/LDvF33JKjzQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "tags": []
     },
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Init Loss:\n",
      "tf.Tensor(8.763554, shape=(), dtype=float32)\n"
     ]
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "\n",
    "plt.scatter(inputs, outputs, c='b')\n",
    "plt.scatter(inputs, model(inputs), c='r')\n",
    "plt.show()\n",
    "\n",
    "# 当前loss\n",
    "print('Init Loss:')\n",
    "print(loss(model(inputs), outputs))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "cl3fhKTSGpXY"
   },
   "source": [
    "## 4.定义训练循环\n",
    "我们现在已经有了模型和训练数据。 我们准备开始训练，即使用训练数据来更新模型的变量（W和b），以便使用梯度下降来减少损失。 在tf.train.Optimizer中实现了许多梯度下降方案的变体。 强烈建议大家使用这些实现，但本着从第一原则构建的精神，在这个特定的例子中，我们将自己实现基本的优化器。\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "MB5j9idIFlLg"
   },
   "outputs": [],
   "source": [
    "def train(model, inputs, outputs, learning_rate):\n",
    "    # 记录loss计算过程\n",
    "    with tf.GradientTape() as t:\n",
    "        current_loss = loss(model(inputs), outputs)\n",
    "        # 对W，b求导\n",
    "        dW, db = t.gradient(current_loss, [model.W, model.b])\n",
    "        # 减去梯度×学习率\n",
    "        model.W.assign_sub(dW*learning_rate)\n",
    "        model.b.assign_sub(db*learning_rate)\n",
    "        "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "4Zl7MUDkIPxU"
   },
   "source": [
    "我们反复训练模型，并观察W和b的变化\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 449
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 767,
     "status": "ok",
     "timestamp": 1559226636263,
     "user": {
      "displayName": "Will Chen",
      "photoUrl": "",
      "userId": "01179718990779759737"
     },
     "user_tz": -480
    },
    "id": "v3xP2b8uII0w",
    "outputId": "70e06a49-9838-4c43-e838-ac5529522f51"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch  0: W=5.00 b=0.00, loss=8.76355\n",
      "Epoch  1: W=4.61 b=0.40, loss=5.97410\n",
      "Epoch  2: W=4.30 b=0.72, loss=4.18118\n",
      "Epoch  3: W=4.05 b=0.98, loss=3.02875\n",
      "Epoch  4: W=3.85 b=1.18, loss=2.28800\n",
      "Epoch  5: W=3.69 b=1.35, loss=1.81184\n",
      "Epoch  6: W=3.56 b=1.48, loss=1.50577\n",
      "Epoch  7: W=3.46 b=1.58, loss=1.30901\n",
      "Epoch  8: W=3.38 b=1.67, loss=1.18253\n",
      "Epoch  9: W=3.31 b=1.73, loss=1.10123\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAW4AAAD8CAYAAABXe05zAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAb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+uBTcB27/1LwbYq+VIluKUOzrnWwPPABO/9jqDbEwTn3HBgs/d+QdBtSRHNgUHAI977gcBu\nIG3vCTnnTsT+d14IdAVaOedGBduq5EuV4E5oQ+J04pzLxEL7ae/9n4JuT4DKgYudc2uxEtrXnHPp\nvK30BmCD9z7yP7AZWJCnq3OBD7z3Vd77GuBPQFnAbUq6VAlubUhci3POYTXM5d77B4JuT5C897d6\n7/O89wXY38Vr3vsm36M6HO/9x8CHzrmiAy+dA7wXYJOCth4Y4pxreeDfzTmkwc3ahPacTDZtSByn\nHBgNvOucW3zgtdsO7P0pciPw9IFOzhrgmoDbExjv/dvOuRnAQmw01iLSYBalZk6KiIRMqpRKREQk\nQQpuEZGQUXCLiISMgltEJGQU3CIiIaPgFhEJGQW3iEjIKLhFRELm/wMLsuYJRzYqnAAAAABJRU5E\nrkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "tags": []
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "model= Model()\n",
    "\n",
    "# 收集W，b画图\n",
    "Ws, bs = [], []\n",
    "for epoch in range(10):\n",
    "    Ws.append(model.W.numpy())\n",
    "    bs.append(model.b.numpy())\n",
    "    # 计算loss\n",
    "    current_loss = loss(model(inputs), outputs)\n",
    "    train(model, inputs, outputs, learning_rate=0.1)\n",
    "    print('Epoch %2d: W=%1.2f b=%1.2f, loss=%2.5f' %\n",
    "        (epoch, Ws[-1], bs[-1], current_loss))\n",
    "# 画图\n",
    "# Let's plot it all\n",
    "epochs = range(10)\n",
    "plt.plot(epochs, Ws, 'r',\n",
    "         epochs, bs, 'b')\n",
    "plt.plot([TRUE_W] * len(epochs), 'r--',\n",
    "         [TRUE_b] * len(epochs), 'b--')\n",
    "plt.legend(['W', 'b', 'true W', 'true_b'])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "0dzWsRsEIcQ7"
   },
   "outputs": [],
   "source": [
    " "
   ]
  }
 ],
 "metadata": {
  "colab": {
   "name": "custom_training_base.ipynb",
   "provenance": [],
   "version": "0.3.2"
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
